package com.zhl.common.enums;

import lombok.Getter;
import lombok.AllArgsConstructor;

/**
 * @description TODO
 * @Author: z156940l@outlook.com
 * @className IoEnum
 * @Date: 2024/7/20 23:31
 */
@Getter
@AllArgsConstructor
public enum IoEnum implements IEnum<Integer, String> {

    TENCENT_CLOUD(1, "腾讯云"),
    ALIBABA_CLOUD(2, "阿里云"),
    ;

    /**
     * 状态码
     */
    private Integer code;

    /**
     * 状态描述
     */
    private String msg;

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * 根据编码查找枚举
     *
     * @param code 编码
     * @return {@link IoEnum } 实例
     **/
    public static IoEnum find(Integer code) {
        for (IoEnum instance : IoEnum.values()) {
            if (instance.getCode().equals(code)) {
                return instance;
            }
        }
        return null;
    }
}
